package com.imyyq.sample.db

import com.imyyq.mvvm.base.DataBindingBaseActivity
import com.imyyq.sample.BR
import com.imyyq.sample.R
import com.imyyq.sample.databinding.ActivityDbBinding
import kotlinx.coroutines.*
import java.lang.Runnable
import kotlin.coroutines.suspendCoroutine

class DBActivity : DataBindingBaseActivity<ActivityDbBinding, DBViewModel>(
    R.layout.activity_db, BR.viewModel
) {

    override fun initData() {
        super.initData()
        runBlocking {
            launch {
                test()
            }

            launch {
                delay(1000)
            }
            coroutineScope {
                launch {

                }
            }
        }

        var job = Job()
        var coroutineScope = CoroutineScope(job)
        coroutineScope.launch {

        }
        coroutineScope.launch {
            val result = async {
                5 + 5
            }.await()
        }



    }

    fun hasZero(ints:List<Int>):Boolean{
        ints.forEach {
            if (it == 0){
                return true
            }
        }
        return false
    }

    inline fun m (crossinline body: () -> Unit){
        val f =    object :Runnable{
            override fun run() = body()
        }
    }

    suspend fun testCor() = coroutineScope {

    }

    suspend fun  test(){
        m {
            return@m
        }
        delay(1000)
    }
}